Skip to content

feat: add graceful shutdown drain for /api/exports - #709

Merged
greatest0fallt1me merged 3 commits into
Predictify-org:mainfrom
Tonyfash:issue-612-exports-drain
Jul 29, 2026
Merged

feat: add graceful shutdown drain for /api/exports#709
greatest0fallt1me merged 3 commits into
Predictify-org:mainfrom
Tonyfash:issue-612-exports-drain

Conversation

@Tonyfash

Copy link
Copy Markdown
Contributor

This PR adds a graceful shutdown drain for /api/exports routes (Closes #612). On SIGTERM/SIGINT, in-flight export requests are allowed to finish before the server exits.

Changes:

  • src/routes/exports.ts: Added in-flight request tracking with inFlightExportsRequests counter, exportsInFlightMiddleware using res.once('finish'/'close') cleanup (matching the pattern from auth.ts), and drainExportsRequests function
  • src/server.ts: Imported and called drainExportsRequests(4000) during shutdown alongside the existing search drain

Add in-flight request tracking and drain mechanism for /api/exports
routes, following the same pattern used by /api/search and /api/auth.
The SIGTERM handler in server.ts now waits for exports requests to
complete before exiting.

Closes Predictify-org#612
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Tonyfash Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit 47aa325 into Predictify-org:main Jul 29, 2026
1 check passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Green ✅ merging. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add graceful shutdown drain for /api/exports [b#038]

2 participants